#include "kdcsubtitlesconfigpage.h"

#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>

#include <KLocale>

#include "kdcsubtitlesconfig.h"

KDCSubtitlesConfigPage::KDCSubtitlesConfigPage( QWidget * parent ) : KDCConfigPageInterface( parent )
{
	kcfg_Codec = new KDCTextCodecComboBox( this );
	kcfg_Add = new QCheckBox( i18n("Automaticaly Add Subtitles"), this );
	kcfg_Size = new KIntSpinBox( this );
	kcfg_Size->setRange( 10, 40 );

	QHBoxLayout *hLayout_1 = new QHBoxLayout;
	hLayout_1->addWidget( new QLabel( i18n("Text Encoding:") ) );
	hLayout_1->addWidget( kcfg_Codec );

	QHBoxLayout *hLayout_2 = new QHBoxLayout;
	hLayout_2->addWidget( new QLabel( i18n("Text Size:") ) );
	hLayout_2->addWidget( kcfg_Size );

	QVBoxLayout *mainLayout = new QVBoxLayout;
	mainLayout->addLayout( hLayout_1 );
	mainLayout->addLayout( hLayout_2 );
	mainLayout->addWidget( kcfg_Add );
	mainLayout->addStretch();
	setLayout( mainLayout );
}

KDCSubtitlesConfigPage::~KDCSubtitlesConfigPage()
{

}

void KDCSubtitlesConfigPage::load()
{
	kcfg_Size->setValue( KDCSubtitleEditorConfig::size() );
	kcfg_Add->setChecked( KDCSubtitleEditorConfig::add() );
	kcfg_Codec->setCurrentCodec( KDCSubtitleEditorConfig::codec() );
}

void KDCSubtitlesConfigPage::save()
{
	KDCSubtitleEditorConfig::setSize( kcfg_Size->value() );
	KDCSubtitleEditorConfig::setAdd( kcfg_Add->isChecked() );
	KDCSubtitleEditorConfig::setCodec( kcfg_Codec->currentCodec() );
}
